//
//  SharedData.swift
//  focusOn
//
//  Created by 恒 on 2025/7/17.
//

import Foundation
import WidgetKit

struct SharedDataStore {
    private static let appGroup = "group.your.app.identifier"
    private static let sharedKey = "sharedTextData"
        
    static var sharedText: Double {
        get {
            return UserDefaults(suiteName: appGroup)?.double(forKey: sharedKey) ?? 0.1
        }
        set {
            UserDefaults(suiteName: appGroup)?.set(newValue, forKey: sharedKey)
            WidgetCenter.shared.reloadAllTimelines() // 通知小组件刷新
        }
    }
    
    static var sharedStr: String {
        get {
            return UserDefaults(suiteName: appGroup)?.string(forKey: sharedKey) ?? "暂无数据"
        }
        set {
            UserDefaults(suiteName: appGroup)?.set(newValue, forKey: sharedKey)
            WidgetCenter.shared.reloadAllTimelines() // 通知小组件刷新
        }
    }
}

